import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  routes: [
    /**
     * 首页
     */
    {
      path: '/',
      name: 'index',
      component (resolve) {
        require(['@/components/index.vue'],resolve)
      }
    },

    /**
     * 登录注册页
     */
    {
      path: '/login',
      name: 'login',
      component (resolve) {
        require(['@/components/login.vue'],resolve)
      }
    },

    /**
     * 二级页面
     */
    {
      path: '/:code',
      name: 'secondary',
      component (resolve) {
        require(['@/components/secondary.vue'],resolve)
      }
    },

    /**
     * 书的列表页面
     */
    {
      path: '/:code/list',
      name: 'list',
      component (resolve) {
        require(['@/components/list.vue'],resolve)
      }
    },

    /**
     * 章节列表页面
     */
    {
      path: '/:code/list/:id',
      name: 'book-section',
      component (resolve) {
        require(['@/components/section.vue'],resolve)
      }
    },

    /**
     * 指定章节内容
     */
    {
      path: '/:code/list/:id/:cid',
      name: 'book-content',
      component (resolve) {
        require(['@/components/content.vue'],resolve)
      }
    },

    /**
     * 我的书架
     */
    {
      path: '/my/book-shelves',
      name: 'book-shelves',
      component (resolve) {
        require(['@/components/bookshelves.vue'],resolve)
      }
    },
    /**
     * 充值
     */
    {
      path: '/my/recharge',
      name: 'recharge',
      component (resolve) {
        require(['@/components/recharge.vue'],resolve)
      }
    },

    /**
     * 移动端
     */
    {
      path: '/book/search',
      name: 'search',
      component(resolve){
        require(['@/components/m/search.vue'],resolve)
      }
    }
  ]
})
